package com.ruoyi.aitcommon.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.aitcommon.domain.TmpTable1;
import com.ruoyi.aitcommon.service.ITmpTable1Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 测试节点1Controller
 * 
 * @author ruoyi
 * @date 2022-02-15
 */
@RestController
@RequestMapping("/aitcommon/table1")
public class TmpTable1Controller extends BaseController
{
    @Autowired
    private ITmpTable1Service tmpTable1Service;

    /**
     * 查询测试节点1列表
     */
    @PreAuthorize("@ss.hasPermi('aitcommon:table1:list')")
    @GetMapping("/list")
    public TableDataInfo list(TmpTable1 tmpTable1)
    {
        startPage();
        List<TmpTable1> list = tmpTable1Service.selectTmpTable1List(tmpTable1);
        return getDataTable(list);
    }

    /**
     * 导出测试节点1列表
     */
    @PreAuthorize("@ss.hasPermi('aitcommon:table1:export')")
    @Log(title = "测试节点1", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TmpTable1 tmpTable1)
    {
        List<TmpTable1> list = tmpTable1Service.selectTmpTable1List(tmpTable1);
        ExcelUtil<TmpTable1> util = new ExcelUtil<TmpTable1>(TmpTable1.class);
        return util.exportExcel(list, "测试节点1数据");
    }

    /**
     * 获取测试节点1详细信息
     */
    @PreAuthorize("@ss.hasPermi('aitcommon:table1:query')")
    @GetMapping(value = "/{code}")
    public AjaxResult getInfo(@PathVariable("code") String code)
    {
        return AjaxResult.success(tmpTable1Service.selectTmpTable1ById(code));
    }

    /**
     * 新增测试节点1
     */
    @PreAuthorize("@ss.hasPermi('aitcommon:table1:add')")
    @Log(title = "测试节点1", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TmpTable1 tmpTable1)
    {
        return toAjax(tmpTable1Service.insertTmpTable1(tmpTable1));
    }

    /**
     * 修改测试节点1
     */
    @PreAuthorize("@ss.hasPermi('aitcommon:table1:edit')")
    @Log(title = "测试节点1", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TmpTable1 tmpTable1)
    {
        return toAjax(tmpTable1Service.updateTmpTable1(tmpTable1));
    }

    /**
     * 删除测试节点1
     */
    @PreAuthorize("@ss.hasPermi('aitcommon:table1:remove')")
    @Log(title = "测试节点1", businessType = BusinessType.DELETE)
	@DeleteMapping("/{codes}")
    public AjaxResult remove(@PathVariable String[] codes)
    {
        return toAjax(tmpTable1Service.deleteTmpTable1ByIds(codes));
    }
}
